package org.lex.app.sessions;

import java.awt.Component;

import javax.swing.JSplitPane;

public class JSplitPaneSession extends AbstractSession {
	private static final String DIVIDER_LOCATION = "dividerLocation";
	private static final String ORIENTATION = "orientation";

	@Override
	public Session getComponentProperties(Component c) {
		this.clear();
		JSplitPane sp = (JSplitPane) c;
		this.putInt(DIVIDER_LOCATION, sp.getDividerLocation());
		this.putInt(ORIENTATION, sp.getOrientation());
		return this;
	}

	@Override
	public void restoreComponent(Component c) {
		int loc = this.getInt(DIVIDER_LOCATION, -1);
		JSplitPane sp = (JSplitPane) c;
		if (-1 != loc)
			sp.setDividerLocation(loc);
		int ori = this.getInt(ORIENTATION, -1);
		if (-1 != ori)
			sp.setOrientation(ori);
	}
}
